import { message as mRequest, app1 as request } from '@/api/request';
/**
 * @description 发送信息
 * @method Post
 */
export function getSendMessage<R, T>(data: any) {
  return mRequest.Post<R, T>('/sendShortMessage', data, {
    headers: {
      'Content-Type': 'application/json;charset-UTF-8',
      'X-APP-ID': '7932dcc94e4648823c0f364e4ec677e8',
      'X-APP-KEY': 'b079aa0cb63f47431d576abc2d489908',
      'X-CTG-Province-ID': 'String',
      'X-CTG-VERSION': 'V1.0.00',
    },
  });
}

/**
 * @description 发送信息(后端)
 * @method Post
 */
export function sendUccpMessage<R, T>(data: any) {
  return request.Post<R, T>('/app1-UccpMessage/sendUccpMessage', {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    params: {
      accNbr: data.accNbr,
      orderContent: data.orderContent,
      requestTime: data.requestTime,
    },
  });
}

/**
 * @description 批量发送信息(后端)
 * @method Post
 */
export function sendMoreUccpMessage<R, T>(messageDTOs: any) {
  return request.Post<R, T>('/app1-UccpMessage/sendMoreUccpMessage', messageDTOs, {
    headers: {
      'Content-Type': 'application/json;charset-UTF-8',
    },
  });
}

/**
 * @description 调用getSendMessage时需要新增记录
 * @method Put
 */
export function insertUccpMessageParams<R, T>(data: any) {
  return request.Put<R, T>('/app1-UccpMessage/insertUccpMessageParams', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 修改记录
 * @method Post
 */
export function updateUccpMessageParams<R, T>(data: any) {
  return request.Post<R, T>('/app1-UccpMessage/updateUccpMessageParams', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 查询全部记录
 * @method Get
 */
export function getAllMessageHistory<R, T>() {
  return request.Get<R, T>('/app1-UccpMessage/queryAllUccpMessageParams', {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * @description 查询全部记录
 * @method Post
 */
export function getMessageHistory<R, T>(currentPage: number, pageSize: number) {
  const data = {
    currentPage,
    pageSize,
    doSearchTotal: true,
  };
  return request.Post<R, T>('/app1-UccpMessage/queryPageUccpMessageParams', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 导出专票信息excel模板
 * @method Get
 */
export function exportTicketTemplate<R, T>() {
  return request.Get<R, T>('/app1-UccpMessage/exportTicketTemplate', {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    responseType: 'blob',
  });
}

/**
 * @description 导入短信文档录入数据库
 * @method Post
 */
export function messageFileupload<R, T>(data: any) {
  return request.Post<R, T>('/app1-UccpMessage/Fileupload', data, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}

/**
 * @description 查询所有短信草稿记录
 * @method Get
 */
export function getCGMessage<R, T>() {
  return request.Get<R, T>('/app1-UccpMessage/Messagelist', {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * @description 批量发送信息(后端)
 * @method Post
 */
export function sendMoreMessage<R, T>() {
  return request.Post<R, T>('/app1-UccpMessage/sendMoreMessage', {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * @description 删除短信记录
 * @method Delete
 */
export function deleteCGMessage<R, T>(id: number) {
  return request.Delete<R, T>(`/app1-UccpMessage/delete/${id}`, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * @description 分页查询升序
 * @method Post
 */
export function getMessageHistoryUP<R, T>(currentPage: number, pageSize: number) {
  const data = {
    currentPage,
    pageSize,
    doSearchTotal: true,
  };
  return request.Post<R, T>('/app1-UccpMessage/queryPageUccpMessageParamsAsc', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 分页查询降序
 * @method Post
 */
export function getMessageHistoryDown<R, T>(currentPage: number, pageSize: number) {
  const data = {
    currentPage,
    pageSize,
    doSearchTotal: true,
  };
  return request.Post<R, T>('/app1-UccpMessage/queryPageUccpMessageParamsDesc', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 查询所有短信记录（分页）
 * @method Post
 */
export function getCGMessageByPage<R, T>(currentPage: number, pageSize: number) {
  const data = {
    currentPage,
    pageSize,
  };
  return request.Post<R, T>('/app1-UccpMessage/getAllMessagesPage', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 查询所有短信记录（分页升序）
 * @method Post
 */
export function getCGMessageByPageUP<R, T>(currentPage: number, pageSize: number) {
  const data = {
    currentPage,
    pageSize,
  };
  return request.Post<R, T>('/app1-UccpMessage/getAllMessagesPageAsc', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 查询所有短信记录（分页倒序）
 * @method Post
 */
export function getCGMessageByPageDown<R, T>(currentPage: number, pageSize: number) {
  const data = {
    currentPage,
    pageSize,
  };
  return request.Post<R, T>('/app1-UccpMessage/getAllMessagesPageDesc', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 修改短信记录
 * @method Put
 */
export function updateCGMessage<R, T>(id: number, phoneNumber: string, messageContent: string) {
  const data = {
    id,
    phoneNumber,
    messageContent,
  };
  return request.Put<R, T>('/app1-UccpMessage/update', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 创建短信记录
 * @method Post
 */
export function addCGMessage<R, T>(phoneNumber: string, messageContent: string, storageTime: string) {
  const data = {
    phoneNumber,
    messageContent,
    storageTime,
  };
  return request.Post<R, T>('/app1-UccpMessage/create', data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 批量删除草稿
 * @method Delete
 */
export function deleteCGMessageByIds<R, T>(ids: any[]) {
  return request.Delete<R, T>('/app1-UccpMessage/UccpMessagedeleteids', ids, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 条件查询分页
 * @method Post
 */
export function getMessageByPageAndName<R, T>(currentPage: number, pageSize: number, condition: string) {
  const data = {
    currentPage,
    pageSize,
  };
  return request.Post<R, T>(`/app1-UccpMessage/UccpMessagequeryBySender/?condition=${condition}`, data, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}
